package com.twu.biblioteca.commands;

import com.twu.biblioteca.Biblioteca;

import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class MovieCheckoutCommand extends BibliotecaCommand {
    public static final String SUCCESS_MESSAGE = "Thank you! Enjoy the movie";
    public static final String FAILURE_MESSAGE = "That movie is not available.";

    public MovieCheckoutCommand(InputStream input, PrintStream output, Biblioteca biblioteca) {
        super("Checkout Movie", input, output, biblioteca);
    }

    public boolean run() {
        if (!biblioteca.isLoggedIn()) {
            output.println(NOT_LOGGED_IN);
            return false;
        }

        Scanner scanner = new Scanner(input);

        output.print(MOVIE_TITLE_PROMPT);
        output.println(biblioteca.checkoutMovie(scanner.nextLine())
                ? SUCCESS_MESSAGE
                : FAILURE_MESSAGE);
        return false;
    }
}
